Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): Dry run always in client mode just for yaml manifest validation even with server side apply #564

Merged
merged 8 commits into from
Jan 22, 2024

Conversation

anandf
Copy link
Contributor

@anandf anandf commented Jan 19, 2024

Root Cause:

When server side apply is set to true, dry run is run in server mode. Dry run in server mode will fail if the target namespace is missing. So in cases where the sync option CreateNamespace is set to true, the dry run fails in server mode, and then attempts to re-run in client mode as a fallback mechanism. But the server side apply is still set. This is not a supported configuration in kubectl when --dry-run is set to client, --server-side flag is not supported causing that to fail as well with the below error message

# kubectl apply -k kustomize-guestbook --dry-run=client --server-side -n guestbook -o json
error: --dry-run=client doesn't work with --server-side (did you mean --dry-run=server instead?)

Due to this behaviour, when both CreateNamespace=true and ServerSideApply=true sync options are used, then the app sync fails while trying to validate the rendered yaml manifests.

Solution

If it is a dry run, always run the dry run in client mode --dry-run=client even if the server side apply option is set --server-side. Dry runs are used for validating if the rendered manifests satisfy the yaml correctness. For the actual sync, honour the --server-side apply flag.

Fixes
argoproj/argo-cd#16829
argoproj/argo-cd#13874
argoproj/argo-cd#16840

Copy link

codecov bot commented Jan 19, 2024

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (c1e2359) 54.41% compared to head (cf0191c) 54.42%.

Files Patch % Lines
pkg/utils/kube/resource_ops.go 0.00% 6 Missing ⚠️
pkg/sync/sync_context.go 91.17% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #564   +/-   ##
=======================================
  Coverage   54.41%   54.42%           
=======================================
  Files          41       41           
  Lines        4798     4803    +5     
=======================================
+ Hits         2611     2614    +3     
- Misses       1974     1977    +3     
+ Partials      213      212    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leoluz leoluz self-requested a review January 19, 2024 14:53
Copy link
Contributor

@leoluz leoluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some minor comments.
Otherwise LGTM.
Tks a lot for working on this!

@leoluz
Copy link
Contributor

leoluz commented Jan 19, 2024

@anandf Please fix the DCO check

@anandf anandf force-pushed the new_approach_for_serverside_fix branch from 63a5a72 to b77faaa Compare January 19, 2024 19:14
Copy link
Contributor

@leoluz leoluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants